package com.example.aggregatedemo.arrary.a04Generics;

import java.util.Arrays;

public class MyArraryList<E> implements MyArraryList2<E> {
    Object[] obj=new Object[10];
    int size;

    //泛型方法
    public boolean add(E e){
        obj[size]=e;
        size++;
        return true;
    }

    //泛型的可变参数
    public boolean add(E ...e){
        for (E e1 : e) {
            obj[size]=e1;
            size++;
        }
        return true;
    }

    public E get(int index){
        return (E)obj[index];
    }

    @Override
    public String toString() {
        return "MyArraryList{" +
                "obj=" + Arrays.toString(obj) +
                ", size=" + size +
                '}';
    }
}
